package cn.edu.buaa.cnsatm.traffic_big_data_server.waterway.dao;
import cn.edu.buaa.cnsatm.traffic_big_data_server.util.JDBCUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TyphoonDAO {
    @Deprecated
    public static ResultSet selectAllProhibitNavigationEvents(String top_num){
        String sql = "SELECT * FROM prohibit_navigation_events ORDER BY datetime DESC LIMIT "+top_num;
        Statement stmt = null;
        ResultSet resultSet = null;
        try {
            stmt = JDBCUtil.databaseConnecttion.createStatement();
            resultSet= stmt.executeQuery(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return resultSet;
    }
    public static ResultSet getTopKSeaBlockByTyphoon(int k){
        /**
         * @author: LX
         * @methodName: getTopKSeaBlockByTyphoon
         * @description: 查询前k条因台风导致的禁航
         * @data:
         **/
        //TODO:确认不需要大雾、大风
        String sql = "SELECT block_description, block_start_time FROM road_status WHERE block_description LIKE '%台风%' AND road_type = '水路' ORDER BY block_start_time DESC LIMIT " + String.valueOf(k);
        //String sql = "SELECT block_description, block_start_time FROM road_status WHERE block_reason = '气象' AND road_type = '水路' ORDER BY block_start_time DESC";

        Statement stmt = null;
        ResultSet resultSet = null;
        try {
            stmt = JDBCUtil.databaseConnecttion.createStatement();
            resultSet= stmt.executeQuery(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return resultSet;
    }
    //public static void main()
}
